From dd6c2391d2a1c63a7e0f91a7034043ea248ac991 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 15 Aug 2014 17:27:00 +0000 Subject: [PATCH] GtkFontChooserWidget: Use a better display name for the font Instead of reconstructing a display name from the PangoFontDescription, use the font family and face objects, which have the original font. This lets us get the names of fonts like Noto Sans CJK DemiLight right, which would be shown as Noto Sans CJK SemiLight when mangled via PangoFontDescription, since Pango treats 'DemiLight' as an alias for the SemiLight weight. https://bugzilla.gnome.org/show_bug.cgi?id=733832 --- gtk/gtkfontchooserwidget.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index c3fdf3d035..1edd2cd896 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -770,16 +770,18 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column, GtkFontChooserWidget *fontchooser = user_data; PangoFontDescription *font_desc; PangoAttrList *attrs; - char *to_string, *text; + char *preview_title, *text; gsize first_line_len; font_desc = tree_model_get_font_description (tree_model, iter); - to_string = pango_font_description_to_string (font_desc); + gtk_tree_model_get (tree_model, iter, + PREVIEW_TITLE_COLUMN, &preview_title, + -1); + + text = g_strconcat (preview_title, "\n", fontchooser->priv->preview_text, NULL); + first_line_len = strlen (preview_title) + 1; - text = g_strconcat (to_string, "\n", fontchooser->priv->preview_text, NULL); - first_line_len = strlen (to_string) + 1; - attrs = gtk_font_chooser_widget_get_preview_attributes (fontchooser, font_desc, first_line_len); @@ -791,7 +793,6 @@ gtk_font_chooser_widget_cell_data_func (GtkTreeViewColumn *column, pango_font_description_free (font_desc); pango_attr_list_unref (attrs); - g_free (to_string); g_free (text); } -- 2.30.2